package demo8;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


public class Person {
    private String name;
    private int age;

    // 无参构造器（Spring需要）
    public Person() {}

    // 全参构造器（用于@Bean创建）
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    // 使用属性注入（可选）

    public void setName(String name) {
        this.name = name;
    }


    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    @Override
    public String toString() {
        return "Person{name = " + name + ", age = " + age + "}";
    }
}
